from selenium.webdriver.common.by import By

from page_object.base_page import BasePage
from page_object.commodity_info import CommodityInfoPage


class CommodityClassPage(BasePage):
    _COMMODITY_IMAGE = (By.CSS_SELECTOR, '.gl-warp a')
    _COMMODITY_TEXT = (By.CSS_SELECTOR, 'li>a.p-name>em')

    def click_commodity_image(self):
        """点击第一个商品"""
        self.find_and_click(self._COMMODITY_IMAGE)
        self.switch_to_next_windows()
        return CommodityInfoPage(self.driver)

